package com.wangsh.usersCenter.web.back.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wangsh.usersCenter.common.controller.BaseController;
import com.wangsh.usersCenter.common.pojo.ApiResponse;
import com.wangsh.usersCenter.common.util.ConstatFinalUtil;
import com.wangsh.usersCenter.common.util.PageInfoUtil;
import com.wangsh.usersCenter.common.util.RedisUtil;
import com.wangsh.usersCenter.users.pojo.AAdmins;
import com.wangsh.usersCenter.users.pojo.AMenu;
import com.wangsh.usersCenter.users.pojo.AMenuEnum;
import com.wangsh.usersCenter.users.pojo.ARole;
import com.wangsh.usersCenter.users.pojo.ARoleEnum;
import com.wangsh.usersCenter.users.pojo.ARoleMenu;
import com.wangsh.usersCenter.users.pojo.ARoleMenuEnum;
import com.wangsh.usersCenter.users.service.IRbacDbService;

/**
 * 权限相关的Controller
 * 
 * @author Xh-Win10-Server
 */
@Controller
@RequestMapping("/back/rbac/")
public class RbacBackController extends BaseController
{
	@Resource
	private IRbacDbService rbacDbService;
	@Resource
	private RedisUtil redisUtil;

	/* ==== 菜单管理开始 ==== */
	/**
	 * 菜单管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/menuList")
	public String menuList(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--menuList--");
		/* 分页信息默认当前页为第一页每页10条 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		/* 搜索条件,生成公共的搜索条件 */
		Map<String, Object> condMap = this.proccedSearch(request);
		/*
		 * 查询数据库 所有的数据以JSON的形式返回
		 */
		ApiResponse<AMenu> response = this.rbacDbService.findCondListMenuService(pageInfoUtil, condMap);
		/* 将结果存储到Request中 */
		model.addAttribute("response", response.toJSON());
		return "/back/rbac/menuList";
	}

	/**
	 * 打开添加菜单管理
	 * 
	 * @return
	 */
	@RequestMapping("/menuInsert")
	public String menuInsert()
	{
		ConstatFinalUtil.SYS_LOGGER.info("--menuInsert--");
		return "/back/rbac/menuInsert";
	}

	/**
	 * 添加菜单管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/menuInsertSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String dynastyInsertSubmit(HttpServletRequest request, String pubTimeStr, AMenu menu)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--menuInsertSubmit--");
		// 获取当前登录人的id
		AAdmins admins = (AAdmins) request.getSession().getAttribute("admins");
		/* 为对象赋值 */
		menu.setCreateId(admins.getId());
		menu.setUpdateId(admins.getId());
		menu.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		/* 保存结果 */
		ApiResponse response = this.rbacDbService.saveOneMenuService(menu);
		/*添加菜单会对所有可用菜单有影响,所以清除缓存*/
		this.redisUtil.delete("menuEnable");
		ConstatFinalUtil.SYS_LOGGER.info("--菜单添加返回结果:{}--", response.toJSON());
		return response.toJSON().toJSONString();
	}

	/**
	 * 打开更新菜单管理
	 * 
	 * @return
	 */
	@RequestMapping("/menuUpdate")
	public String dynastyUpdate(String id, String operType, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--menuUpdate--");
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<AMenu> response = this.rbacDbService.findOneMenuService(condMap);
		/* 存储request */
		model.addAttribute("response", response.toJSON());

		if ("update".equalsIgnoreCase(operType))
		{
			return "/back/rbac/menuUpdate";
		}
		return "/back/rbac/menuInfo";
	}

	/**
	 * 更新菜单管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/menuUpdateSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String menuUpdateSubmit(String id, HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--menuUpdateSubmit--");
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<AMenu> response = this.rbacDbService.findOneMenuService(condMap);
		AMenu dataOneJava = response.getDataOneJava();
		int parentIdBefore = dataOneJava.getParentId();
		/* 获取java对象 */
		AMenu menu = response.getDataOneJava();
		// 获取当前登录人的id
		AAdmins admins = (AAdmins) request.getSession().getAttribute("admins");
		/* 接收参数 */
		String name = request.getParameter("name");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		String url = request.getParameter("url");
		String parentIdAfter = request.getParameter("parentId");
		String pubTimeStr = request.getParameter("pubTimeStr");
		/* 设置属性 */
		menu.setUpdateId(admins.getId());
		menu.setParentId(Integer.valueOf(parentIdAfter));
		menu.setUrl(url);
		menu.setName(name);
		menu.setContent(content);
		menu.setStatus(Byte.valueOf(status));
		menu.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		/* 数据库操作 */
		ApiResponse dbRes = rbacDbService.updateOneMenuService(menu);
		//判断更新后的pid和原来的pid是否一样
		if (parentIdBefore!=Integer.valueOf(parentIdAfter))
		{
			condMap.clear();
			condMap.put("parentId", parentIdBefore);
			ApiResponse<AMenu> findCondListMenuService = this.rbacDbService.findCondListMenuService(null,condMap);
			//看看更新后的pid是否有儿子
			if (findCondListMenuService.getCode()==-1||findCondListMenuService.getDataListJava().get(0)==null)
			{
				condMap.put("id",parentIdBefore);
				ApiResponse<AMenu> findOneMenuService = this.rbacDbService.findOneMenuService(condMap);
				AMenu dataOneJava2 = findCondListMenuService.getDataOneJava();
				dataOneJava2.setIsLeafStatus(Byte.valueOf("1"));
				rbacDbService.updateOneMenuService(dataOneJava2);
			}
		}
		condMap.clear();
		condMap.put("menuId",menu.getId()+"");
		ApiResponse<ARoleMenu> findOneRoleMenuService = this.rbacDbService.findOneRoleMenuService(condMap);
		ARoleMenu aRoleMenu = findOneRoleMenuService.getDataOneJava();
		if (aRoleMenu!=null)
		{
			if (status.equals("0")&&aRoleMenu.getStatus()==1)
			{
				aRoleMenu.setStatus(Byte.valueOf(status));
				this.rbacDbService.updateOneRoleMenuService(aRoleMenu);
			}else if (status.equals("1")&&aRoleMenu.getStatus()==0)
			{
				aRoleMenu.setStatus(Byte.valueOf(status));
				this.rbacDbService.updateOneRoleMenuService(aRoleMenu);
			}
		}
		
		this.redisUtil.delete("menuEnable");
		condMap.clear();
		condMap.put("status", 1);
		ApiResponse<ARole> findCondListRoleService = this.rbacDbService.findCondListRoleService(null, condMap);
		List<ARole> dataListJava = findCondListRoleService.getDataListJava();
		for (ARole aRole : dataListJava)
		{  
			this.redisUtil.delete(aRole.getId() + "");
		}
		ConstatFinalUtil.SYS_LOGGER.info("--菜单更新返回结果:{}--", dbRes.toJSON());
		return dbRes.toJSON().toJSONString();
	}
	/* ==== 菜单管理结束 ==== */

	/* ==== 角色管理开始 ==== */
	/**
	 * 角色管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/roleList")
	public String roleList(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleList--");
		/* 分页信息 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		/* 搜索条件,生成公共的搜索条件 */
		Map<String, Object> condMap = this.proccedSearch(request);
		/*
		 * 查询数据库 所有的数据以JSON的形式返回
		 */
		ApiResponse<ARole> response = this.rbacDbService.findCondListRoleService(pageInfoUtil, condMap);
		/* 将结果存储到Request中 */
		model.addAttribute("response", response.toJSON());
		return "/back/rbac/roleList";
	}

	/**
	 * 打开添加角色管理
	 * 
	 * @return
	 */
	@RequestMapping("/roleInsert")
	public String roleInsert()
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleInsert--");
		return "/back/rbac/roleInsert";
	}

	/**
	 * 添加角色管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/roleInsertSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String roleInsertSubmit(HttpServletRequest request, String pubTimeStr, ARole role)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleInsertSubmit--");
		/* 为对象赋值 */
		AAdmins admins = (AAdmins) request.getSession().getAttribute("admins");
		role.setCreateId(admins.getId());
		role.setUpdateId(admins.getId());
		role.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		role.setCreateTime(new Date());
		role.setUpdateTime(new Date());
		/* 保存结果 */
		ApiResponse response = this.rbacDbService.saveOneRoleService(role);
		ConstatFinalUtil.SYS_LOGGER.info("--角色添加返回结果:{}--", response.toJSON());
		return response.toJSON().toJSONString();
	}

	/**
	 * 打开更新角色管理
	 * 
	 * @return
	 */
	@RequestMapping("/roleUpdate")
	public String roleUpdate(String id, String operType, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleUpdate--");
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<ARole> response = this.rbacDbService.findOneRoleService(condMap);
		/* 存储request */
		model.addAttribute("response", response.toJSON());
		if ("update".equalsIgnoreCase(operType))
		{
			return "/back/rbac/roleUpdate";
		}
		return "/back/rbac/roleInfo";
	}

	/**
	 * 更新角色管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/roleUpdateSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String roleUpdateSubmit(String id, HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleUpdateSubmit--");
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<ARole> response = this.rbacDbService.findOneRoleService(condMap);
		/* 获取java对象 */
		ARole role = response.getDataOneJava();
		/* 为对象赋值,接收参数 */
		AAdmins admins = (AAdmins) request.getSession().getAttribute("admins");
		String name = request.getParameter("name");
		String content = request.getParameter("content");
		String status = request.getParameter("status");
		String pubTimeStr = request.getParameter("pubTimeStr");
		/* 设置属性 */
		role.setUpdateId(admins.getId());
		role.setName(name);
		role.setContent(content);
		role.setStatus(Byte.valueOf(status));
		role.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		role.setUpdateTime(new Date());
		/* 数据库操作 */
		ApiResponse dbRes = rbacDbService.updateOneRoleService(role);
		ConstatFinalUtil.SYS_LOGGER.info("--角色添加返回结果:{}--", dbRes.toJSON());
		return dbRes.toJSON().toJSONString();
	}

	/**
	 * 角色授权->异步请求保存方法
	 * 
	 * @param request
	 * @param roleId
	 * @param menuId
	 * @return
	 */
	@RequestMapping(value = "/saveRoleMenu", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String saveRoleMenu(HttpServletRequest request, String roleId, String menuId)
	{
		String[] menusId = menuId.split(",");
		List List = new ArrayList(Arrays.asList(menusId));
		List menusIdList = new ArrayList();
		Set set = new HashSet();
		set.addAll(List);
		menusIdList.addAll(set);
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", roleId);
		ApiResponse<ARoleMenu> apiResponse = rbacDbService.findCondListRoleMenuService(null, condMap);
		List<ARoleMenu> dataListJava = apiResponse.getDataListJava();
		for (int i = 0; i < dataListJava.size(); i++)
		{
			rbacDbService.deleteOneRoleMenuService(condMap);
		}
		int j = 0;
		for (int i = 0; i < menusIdList.size(); i++)
		{
			ARoleMenu roleMenu = new ARoleMenu();
			roleMenu.setRoleId(Integer.parseInt(roleId));
			roleMenu.setMenuId(Integer.parseInt((String) menusIdList.get(i)));
			roleMenu.setCreateTime(new Date());
			roleMenu.setPubTime(new Date());
			roleMenu.setUpdateTime(new Date());
			rbacDbService.saveOneRoleMenuService(roleMenu);
			j++;
		}
		String Code;
		if (j > 0)
		{
			Code = "0";
		} else
		{
			Code = "1";
		}
		return Code;
	}

	/**
	 * 角色授权
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("/roleAuth")
	public String roleAuth(HttpServletRequest request)
	{
//		String id = request.getParameter("id");
		String id = request.getParameter("roleId");
		Map<String, Object> condMap = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		condMap.put("roleId", id);
		ApiResponse<ARoleMenu> findCondListRoleMenuService = rbacDbService.findCondListRoleMenuService(null, condMap);
		List<ARoleMenu> aRoleMenus = findCondListRoleMenuService.getDataListJava();
		List<String> MenuIds = new ArrayList<String>();
		for (int i = 0; i < aRoleMenus.size(); i++)
		{
			MenuIds.add(aRoleMenus.get(i).getMenuId() + "");
		}
		ApiResponse<AMenu> findCondListMenuService = rbacDbService.findCondListMenuService(null, map);
		List<AMenu> menus = findCondListMenuService.getDataListJava();
		request.setAttribute("roleId", id);
		request.setAttribute("menus", menus);
		request.setAttribute("MenuIds", MenuIds);
		return "/back/rbac/roleAuth";
	}
	/* ==== 角色管理结束 ==== */

	/* ==== 角色菜单管理开始 ==== */
	/**
	 * 角色菜单管理页面
	 * 
	 * @return
	 */
	@RequestMapping("/roleMenuList")
	public String roleMenuList(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuList--");
		/* 分页信息 */
		PageInfoUtil pageInfoUtil = this.proccedPageInfo(request);
		/* 搜索条件,生成公共的搜索条件 */
		Map<String, Object> condMap = this.proccedSearch(request);
		/*
		 * 查询数据库 所有的数据以JSON的形式返回
		 */
		ApiResponse<ARoleMenu> response = this.rbacDbService.findCondListRoleMenuService(pageInfoUtil, condMap);
		/* 将结果存储到Request中 */
		model.addAttribute("response", response.toJSON());
		return "/back/rbac/roleMenuList";
	}

	/**
	 * 打开添加角色菜单管理
	 * 
	 * @return
	 */
	@RequestMapping("/roleMenuInsert")
	public String roleMenuInsert(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuInsert--");

		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("status", ARoleEnum.STATUS_ENABLE.getStatus());
		// 查询所有角色
		ApiResponse<ARole> roleResponse = this.rbacDbService.findCondListRoleService(null, condMap);
		/* 所有菜单 */
		ApiResponse<AMenu> menuRsponse = this.rbacDbService.findCondListMenuService(null, condMap);
		// 转换格式
		List<ARole> roleResponseList = roleResponse.getDataListJava();
		List<AMenu> menResponseList = menuRsponse.getDataListJava();
		// 存储域中
		model.addAttribute("roleList", roleResponseList);
		model.addAttribute("menuList", menResponseList);

		return "/back/rbac/roleMenuInsert";
	}

	/**
	 * 添加角色菜单管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/roleMenuInsertSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String roleMenuInsertSubmit(String pubTimeStr, ARoleMenu roleMenu)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuInsertSubmit--");
		/* 为对象赋值 */
		roleMenu.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		roleMenu.setCreateTime(new Date());
		roleMenu.setUpdateTime(new Date());
		/* 保存结果 */
		ApiResponse response = this.rbacDbService.saveOneRoleMenuService(roleMenu);
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("status", 1);
		ApiResponse<ARole> findCondListRoleService = this.rbacDbService.findCondListRoleService(null, condMap);
		List<ARole> dataListJava = findCondListRoleService.getDataListJava();
		for (ARole aRole : dataListJava)
		{   
			this.redisUtil.delete(aRole.getId() + "");
		}
		ConstatFinalUtil.SYS_LOGGER.info("--角色菜单添加返回结果:{}--", response.toJSON());
		return response.toJSON().toJSONString();
	}

	/**
	 * 角色授权(树形结构)-打开
	 * 
	 * @return
	 */
	@RequestMapping("/menuTree")
	public String roleMenuTreeInsert(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuTreeInsert--");
		ApiResponse<AMenu> response = null;
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("status", AMenuEnum.STATUS_ENABLE.getStatus());
		condMap.put("menuTree","menuTree");
		String roleId = request.getParameter("roleId");
		JSONObject json = null;
		if (roleId == null)
		{
			roleId = "";
		} else
		{
			condMap.put("roleId", roleId);
			condMap.put("menuTree","menuTreeRole");
		}
		response = this.rbacDbService.findCondListMenuService(null, condMap);

		Map<String, List<AMenu>> dataList = response.getDataList();
		Set<String> keySet = dataList.keySet();
		JSONObject jsonObject = new JSONObject();
//		json = response.toJSON();
//		model.addAttribute("response1", json);
		for (Iterator iterator = keySet.iterator(); iterator.hasNext();)
		{
			String string = (String) iterator.next();
			List<AMenu> list = dataList.get(string);
			JSONArray json2 = (JSONArray) JSONArray.toJSON(list);
			jsonObject.put("list"+string, json2);
		}

		/* 将结果存储到Request中 */
		model.addAttribute("response", jsonObject);
		if (!"".equalsIgnoreCase(roleId))
		{
			condMap.clear();
			condMap.put("id", roleId);
			ApiResponse<ARole> roleResponse = this.rbacDbService.findOneRoleService(condMap);
			/* 将结果存储到Request中 */
			model.addAttribute("roleResponse", roleResponse.toJSON());
		}
		return "/back/rbac/menuTree";
	}

	/**
	 * 角色授权(树形结构)-提交
	 * 
	 * @return
	 */
	@RequestMapping(value = "/roleMenuTreeInsertSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String roleMenuTreeInsertSubmit(HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuTreeInsertSubmit--");
		AAdmins admins = (AAdmins) this.findObjfromSession(request, "admins");
		ApiResponse<Object> apiResponse = new ApiResponse<Object>();
		List<Map> list = new ArrayList<Map>();
		/* 从session中获取信息 */
		String[] menuIds = request.getParameterValues("menuId");

		/* 操作类型 */
		String roleId = request.getParameter("roleId");

		/* 先删除当前角色id下面所有的记录 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("roleId", roleId);
		ApiResponse<Object> deleteOneRoleMenuService = this.rbacDbService.deleteOneRoleMenuService(condMap);
		ConstatFinalUtil.SYS_LOGGER.info("删除角色:{},操作人:{},信息:{}", roleId, admins.getId(), apiResponse.toJSON());
		if (menuIds != null)
		{
			int totalNum = menuIds.length;
			int succedNum = 0;
			int failedNum = 0;
			ARoleMenu roleMenu = new ARoleMenu();
			roleMenu.setRoleId(Integer.valueOf(roleId));
			roleMenu.setStatus(Byte.valueOf(ARoleMenuEnum.STATUS_ENABLE.getStatus()));
			for (int i = 0; i < menuIds.length; i++)
			{
				String menuId = menuIds[i];
				roleMenu.setMenuId(Integer.valueOf(menuId));
				roleMenu.setCreateTime(new Date());
				roleMenu.setUpdateTime(new Date());
				roleMenu.setPubTime(new Date());
				list.add(roleMenu.toJSON());
				/*
				 * ApiResponse<Object> roleMenuResponse =
				 * this.rbacService.saveOneRoleMenuService(roleMenu); if
				 * (roleMenuResponse.getCode() == ApiResponseEnum.STATUS_SUCCESS.getStatus()) {
				 * succedNum++; } else { failedNum++; }
				 */
			}
			apiResponse = this.rbacDbService.saveBatchRoleMenuService(list);
			/*
			 * StringBuffer sb = new StringBuffer(); sb.append("总条数:" + totalNum + ";");
			 * sb.append("成功条数:" + succedNum + ";"); sb.append("失败条数:" + failedNum + ";");
			 * apiResponse.setCode(ApiResponseEnum.STATUS_SUCCESS.getStatus());
			 * apiResponse.setInfo(sb.toString(), Collections.EMPTY_MAP);
			 */
		}
		this.redisUtil.delete(roleId);
		return apiResponse.toJSON().toJSONString();
	}

	/**
	 * 打开更新角色菜单管理
	 * 
	 * @return
	 */
	@RequestMapping("/roleMenuUpdate")
	public String roleMenuUpdate(String id, String operType, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuUpdate--");
		
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<ARoleMenu> response = this.rbacDbService.findOneRoleMenuService(condMap);
		/* 存储request */
		model.addAttribute("response", response.toJSON());

		if ("update".equalsIgnoreCase(operType))
		{
			return "/back/rbac/roleMenuUpdate";
		}
		return "/back/rbac/roleMenuInfo";
	}

	/**
	 * 更新角色菜单管理提交操作
	 * 
	 * @return
	 */
	@RequestMapping(value = "/roleMenuUpdateSubmit", produces = "text/html;charset=UTF-8")
	@ResponseBody
	public String roleMenuUpdateSubmit(String id, HttpServletRequest request, Model model)
	{
		ConstatFinalUtil.SYS_LOGGER.info("--roleMenuUpdateSubmit--");
		/* 准备查询条件 */
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", id);
		/* 查询数据库 */
		ApiResponse<ARoleMenu> response = this.rbacDbService.findOneRoleMenuService(condMap);
		/* 获取java对象 */
		ARoleMenu roleMenu = response.getDataOneJava();

		String status = request.getParameter("status");

		String pubTimeStr = request.getParameter("pubTimeStr");

		roleMenu.setStatus(Byte.valueOf(status));

		roleMenu.setPubTime(this.dateFormatUtil.strDateTime(pubTimeStr));
		roleMenu.setUpdateTime(new Date());
		/* 数据库操作 */
		ApiResponse dbRes = rbacDbService.updateOneRoleMenuService(roleMenu);
		this.redisUtil.delete(roleMenu.getRoleId() + "");
		ConstatFinalUtil.SYS_LOGGER.info("--角色菜单添加返回结果:{}--", dbRes.toJSON());
		return dbRes.toJSON().toJSONString();
	}
	/* ==== 角色菜单管理结束 ==== */
}
